package com.gujia.concurrency.example.singleton;

import com.gujia.concurrency.annoations.NoThreadSafe;
import com.gujia.concurrency.annoations.NotRecommend;
import com.gujia.concurrency.annoations.ThreadSafe;

/**
 * 懒汉模式
 * 单例实例再第一次使用时进行创建
 */
@ThreadSafe
@NotRecommend
public class SingletonExample3 {


    private SingletonExample3(){

    }

    private static SingletonExample3 instance = null;

    public static synchronized SingletonExample3 getInnstance(){
        if(instance == null){
            instance = new SingletonExample3();
        }

        return instance;
    }


}
